home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1005 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.7 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: thp@cs.ucr.edu (Tom Payne)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Referencing pointers after delete
  5. Date: 08 Apr 1996 10:15:58 PDT
  6. Organization: University of California, Riverside
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4ka03d$228@galaxy.ucr.edu>
  9. References: <m0u4G70-000GcEC@7.kurahaupo.gen.nz>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 8 Apr 1996 03:10:37 GMT
  12. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMWlJz0y4NqrwXLNJAQHw/gH/WOEyvwkrwqBJyd0sBdPnfAKwRnUWi0nT
  15.     kndJ2ZWaDupH4hc0EfnX0QU+xfPOc7L5/2/5VMc7PGYjbjEt/JhJPw==
  16.     =phvq
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. Martin D Kealey (martin@kcbbs.gen.nz) wrote:
  20. [...]
  21. : *Sigh*  This is not supposed to be a complete description, just an
  22. : example.  So ok, change it to invalidate all registers which
  23. : contain pointers to the same type as p, not just the single
  24. : register which contains the value of p.  Also, *all* registers are
  25. : invalidated over (non-inline) function calls, or any other time
  26. : we're not 100% sure what they might contain.
  27. : I think now that accidental use of register aliasing is not
  28. : possible -- one has explicitly to use p (or an alias for it) as a
  29. : non-lvalue in the source code to cause this effect, and that means
  30. : the program is non-conforming.
  31.  
  32. Agreed.  With a sufficiently conservative invalidation policy, the
  33. implementation conforms.  So, would it continue to conform if a valid
  34. program could read an invalid pointer (a pointer object at a time when
  35. it happens to hold an invalid value)?  I think so.  The implementation
  36. can freely assume that a pointer object holds a valid value from the
  37. time it is assigned that value until it is invalidated, since, if the
  38. assigned value was invalid, then the implementation is off the hook
  39. via "undefined behavior."  It would make no difference whether that 
  40. invalid value was generated by reading a pointer to a deleted object
  41. or though assigning the presumably invalid value (int*)1.
  42.  
  43. : I know this is a perverse implementation that does some pretty
  44. : fantastic peephole optimising without bothering to do any dataflow
  45. : analysis, but that alone doesn't currently make it non-conforming.
  46.  
  47. Right!  Besides, it shows that one could possibly lose opportunities
  48. for optimization if it were permitted to assign invalid values to
  49. a pointer object.
  50.  
  51. Tom Payne (thp@cs.ucr.edu)
  52. ---
  53. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  54.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  55.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  56.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  57.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  58. ]
  59.